<template>
	<view>
<!-- 		<view class="head">
			<image :src="headImg?headImg:'../../static/my/tx.png'" mode="widthFix"></image>
			<view>{{name}}</view>
		</view> -->
		<!-- <view class="phone">
			<view class="title">手机号绑定</view>
			<view class="con">已绑定</view>
		</view>
		<view class="name">
			<view class="title">实名认证</view>
			<view class="con">{{renzhen}}</view>
		</view> -->
		<view class="card">
			<view class="one">
			</view>
			<view class="two">
				<view class="box" v-if="list" v-for="(item,index) in list"  :key="index">
					<view class="bank">
						<view class="">
							<image class="tu" src="http://yunzhidun.oss-cn-beijing.aliyuncs.com/weixin/static/mine/payment.png" mode="widthFix"></image>
							<!-- {{list[0].bankname}} -->
							{{item.bankname}}
						</view>
						<view class="" style="margin: 20rpx 5rpx;">
							<!-- {{list[0].bank}} -->
							{{item.bank}}
						</view>
					</view>
					<view class="icona" @tap="delbankcard(item.id)">
						<image src="../../static/my/close.png" style="width:16px;padding: 10px 5px 10px 15px;" mode="widthFix"></image>
					</view>
				</view>
			</view>
			<!--  v-if="show" -->
			<view class="three" @tap='toaddbank'>
				<image src="../../static/tjdz.png" mode="widthFix" ></image>
				<view class="" >
					添加银行卡
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				name:'',
				headImg:'',
				show:true,
				list:'',
				renzhen:'未认证'
			}
		},
		onLoad(optsions) {

		},
		onShow() {
			this.getbank()
		},
		methods:{
			toaddbank(){
				uni.navigateTo({
					url:'/pages/mine/addBank'
				})
			},
			
			getbank(){
				let userinfo = uni.getStorageSync('userinfo');

				this.$api.interfaceApi('getBank')({
					'user_id':userinfo.id
				}).then(res=>{
					if(res.code == 200){
						var hou = res.data[0].bank.substring(res.data[0].bank.length-4)
						var str = '';
	
						for(var i=0;i<res.data[0].bank.length-4;i++){
							
							if(i %4 == 0 && str.length>0){
								str +=' ';
							}
							str+="*"
						}
						
						//console.log(str+" "+hou)
						res.data[0].bank = str+" "+hou
						this.list = res.data
						// this.show = false
						// this.renzhen = '已认证'
					}

				})
			},
			delbankcard(bankid){
				let _this = this
				uni.showModal({
					title:'提示',
					content:'确定删除该银行卡？',
					confirmText: '确认',
					 success: function (res) {
						if (res.confirm) {
							_this.$api.interfaceApi('delbank')({
								'bank_id':bankid
							}).then(res=>{
								
								// if(res.code == 1){
									uni.showToast({
										title:res.msg,
										icon:'none'
									})
									_this.getbank()
									// this.onPullDownRefresh()
								// }else{
									
								// }
							})
							uni.navigateBack({delta:2})
						} else if (res.cancel) {
							console.log("点击了取消删除")
						}
					}
				})
			
			},
		}
	}
</script>

<style lang="less">
	.head{
		display: flex;
		width: 96%;
		margin: 50rpx auto 0;
		background-color: #FFFFFF;
		border-radius: 20rpx;
		padding: 20rpx 30rpx;
		box-sizing: border-box;
		image{
			width: 120rpx;
			vertical-align: middle;
			border-radius: 50%;
			margin-right: 40rpx;
		}
		view{
			line-height: 120rpx;
		}
	}
	.phone{
		width: 96%;
		margin: 26rpx auto;
		background-color: #FFFFFF;
		border-radius: 15rpx;
		display: flex;
		justify-content: space-between;
		padding: 30rpx 30rpx;
		box-sizing: border-box;
		
		.con{
			color: blue;
		}
		
	}
	.name{
		width: 96%;
		margin: 26rpx auto;
		background-color: #FFFFFF;
		border-radius: 15rpx;
		display: flex;
		justify-content: space-between;
		padding: 30rpx 30rpx;
		box-sizing: border-box;
		
		.con{
			color: red;
		}
	}
	
	.card{
		width: 96%;
		margin: 26rpx auto;
		background-color: #FFFFFF;
		border-radius: 15rpx;
		padding: 20rpx;
		box-sizing: border-box;
		
		.one{
			display: flex;
			margin-bottom: 20rpx;
		}
		
		.two{
			margin-bottom: 20rpx;
			.box{
				display: flex;
				height: 180rpx;
				border: 2rpx solid #e2e2e2;
				// padding: 20rpx 80rpx 0 30rpx;
				padding: 20rpx 10rpx;
				box-sizing: border-box;
				justify-content: space-between;
				border-radius: 30rpx;
				position: relative;
				margin: 34rpx 0;
				.bank{
					width: 80%;
					line-height: 50rpx;
					
					.tu{
						width: 15%;
						vertical-align: middle;
						margin-right: 10rpx;
					}
				}
				
				.shanchu{
					line-height: 68rpx;
				}
				
				.jiao{
					width: 15%;
					position: absolute;
					top:-2rpx;
					right: -2rpx;
					height: 66rpx;
					width: 66rpx;
				}
			}
			.icona{
				width: 12%;
				border-radius: 0  30rpx 0 100%;
				background-color: #4cd964;
				margin-top:-20rpx;
				margin-right:-10rpx;
				height:42px;
			}
		}
		
		
		.three{
			height: 80rpx;
			background-color: #4cd964;
			margin: 0rpx auto;
			border-radius: 20rpx;
			display: flex;
			color: #FFFFFF;
			box-sizing: border-box;
			line-height: 80rpx;
			image{
				width: 36rpx;
				height: 36rpx;
				margin-top: 22rpx;
				margin-left: 220rpx;
				margin-right: 10rpx;
			}
		}
		
	}
</style>
